package com.zhangjh.validator;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.zhangjh.service.HelloService;
/**
 * @MyConstraint  这个注解的逻辑校验处理
 * Object  为放在哪些类型的字段上
 * @author 18702
 *
 */
@Component
public class MyValidator implements ConstraintValidator<MyConstraint, Object> {
	
	@Autowired
	private HelloService helloService;
	
	@Override
	public void initialize(MyConstraint arg0) {
		System.out.println("MyValidator init!");
		
	}

	@Override
	public boolean isValid(Object value, ConstraintValidatorContext arg1) {
		helloService.greeting("tom");
		System.out.println(value);
		return false;
	}

}
